package Day15;

import java.util.Calendar;
import java.util.Date;
import java.util.Objects;

public class Book implements Comparable<Book> {
    private String name;
    private double money;
    private Date time;

    @Override
    public int compareTo(Book o) {
        if(this.money > o.money){
            return 1;
        }else if(this.money == o.money){
            if(this.time.after(o.time)){
                return 1;
            }else if(this.time.equals(o.time)){
                return 0;
            }else {
                return 0;
            }
        }else {
            return -1;
        }
    }


    @Override
    public String toString() {
        return "Book" +
                "name='" + name + '\'' +
                ", money=" + money +
                ", time=" + time +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Book express = (Book) o;
        return Double.compare(express.money, money) == 0 &&
                Objects.equals(name, express.name) &&
                Objects.equals(time, express.time);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, money, time);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public Book(String name, double money, Date time) {
        this.name = name;
        this.money = money;
        this.time = time;
    }

    public Book() {
    }

}
